<template>
  <el-card>
    <el-form :inline="true">
      <el-form-item label="一级分类">
        <el-select
          style="width: 240px"
          v-model="categortStore.categoryInfo.categoryId1"
          @change="handler"
          :disabled="scene == 0 ? false : true"
        >
          <el-option
            v-for="item1 in categortStore.categoryInfo.Category1Data"
            :key="item1.id"
            :label="item1.name"
            :value="item1.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select
          style="width: 240px"
          v-model="categortStore.categoryInfo.categoryId2"
          @change="handler1"
          :disabled="scene == 0 ? false : true"
        >
          <el-option
            v-for="item2 in categortStore.categoryInfo.Category2Data"
            :key="item2.id"
            :label="item2.name"
            :value="item2.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select
          style="width: 240px"
          v-model="categortStore.categoryInfo.categoryId3"
          :disabled="scene == 0 ? false : true"
        >
          <el-option
            v-for="item3 in categortStore.categoryInfo.Category3Data"
            :key="item3.id"
            :label="item3.name"
            :value="item3.id"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import useCategoryStore from '@/store/modules/category'
let categortStore = useCategoryStore()
// 一级分类
const getReqCategory1 = () => {
  categortStore.getReqCategory1()
}

// 一级分类下拉
const handler = () => {
  categortStore.categoryInfo.categoryId2 = ''
  categortStore.categoryInfo.Category3Data = []
  categortStore.categoryInfo.categoryId3 = ''
  categortStore.getReqCategory2()
}

// 二级分类菜单下拉的change
const handler1 = () => {
  categortStore.categoryInfo.categoryId3 = ''
  categortStore.getReqCategory3()
}

onMounted(() => {
  getReqCategory1()
})

// 接收父组件传过来的的scene
defineProps(['scene'])
</script>

<style lang="scss" scoped></style>
